//
//  UITextView+CPText.m
//  ChinaPoem
//
//  Created by 赵俊明 on 2019/3/5.
//  Copyright © 2019 赵俊明. All rights reserved.
//

#import "UITextView+CPText.h"

@implementation UITextView (CPText)
+ (void)load
{
    static dispatch_once_t oToken;
    dispatch_once(&oToken, ^{
        SEL sysel = @selector(willMoveToSuperview:);
        SEL swsel = @selector(cp_toSuperview:);
        Method sysMethod = class_getInstanceMethod([self class], sysel);
        Method swMethod = class_getInstanceMethod([self class], swsel);
        BOOL isAdd = class_addMethod(self, sysel, method_getImplementation(swMethod), method_getTypeEncoding(swMethod));
        if (isAdd) {
            class_replaceMethod(self, swsel, method_getImplementation(sysMethod), method_getTypeEncoding(sysMethod));
        } else {
            method_exchangeImplementations(sysMethod, swMethod);
        }
    });
}

- (void)cp_toSuperview:(UIView *)newSuperview {
    [self cp_toSuperview:newSuperview];
    if (self) {
        if (self) {self.font = kFont(self.font.pointSize);}
    }
}
@end
